Skip to content

feat: Add reusable codeql-analysis-reusable.yml workflow#699

Open
ppkarwasz wants to merge 4 commits intomasterfrom
feat/codeql-reusable
Open

feat: Add reusable codeql-analysis-reusable.yml workflow#699
ppkarwasz wants to merge 4 commits intomasterfrom
feat/codeql-reusable

Conversation

@ppkarwasz
Copy link
Copy Markdown
Contributor

Adds a reusable CodeQL analysis workflow and refactors codeql-analysis.yml to call it instead of running the analysis inline.

Centralizing the workflow in commons-parent means dependency upgrades (e.g. codeql-action) only need to be done once for all repositories. Referencing the master branch is safe because the same PMC controls both commons-parent and the other commons-* repositories.

Adds a reusable CodeQL analysis workflow and refactors
`codeql-analysis.yml` to call it instead of running the analysis
inline.

Centralizing the workflow in `commons-parent` means dependency upgrades
(e.g. `codeql-action`) only need to be done once for all repositories.
Referencing the `master` branch is safe because the same PMC controls
both `commons-parent` and the other `commons-*` repositories.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a reusable CodeQL analysis workflow in this repository and refactors the existing CodeQL workflow to call the reusable one, reducing duplication and making future CodeQL-action upgrades easier to roll out.

Changes:

  • Add a new reusable workflow .github/workflows/codeql-analysis-reusable.yml that runs CodeQL in a language matrix and restores Maven cache.
  • Refactor .github/workflows/codeql-analysis.yml to invoke the reusable workflow instead of defining the full job inline.
  • Add .github/workflows/README.md documenting reusable workflows and the CodeQL reusable workflow usage/permissions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/codeql-analysis.yml Switches to calling the reusable CodeQL workflow; sets minimal top-level permissions and job permissions.
.github/workflows/codeql-analysis-reusable.yml Defines the reusable CodeQL workflow with workflow_call input and CodeQL steps.
.github/workflows/README.md Documents how to use the reusable workflows, including CodeQL inputs and required permissions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/codeql-analysis.yml Outdated
Comment thread .github/workflows/codeql-analysis-reusable.yml Outdated
Comment thread .github/workflows/README.md Outdated
@ppkarwasz
Copy link
Copy Markdown
Contributor Author

For context: from the discussion we had in November I deduce that:

  • We don't want to use the same maven.yml workflow on most repositories, but
  • Common tasks like CodeQL, Scorecards and Dependency Review can be centralized.

This means we could upgrade those three workflows more often, but at the same time have the same churn as updating 40 repositories quarterly.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@garydgregory
Copy link
Copy Markdown
Member

Please, no. I am not a fan of this style of GitHub usage (see Log4j's impossible to understand for a mere mortal set up). I don't want have to be, or other maintainers to become GHA experts. This usage would force a hierarchical set up for builds at the GHA level, and I see the complexity as outweighing any value.

ppkarwasz added a commit that referenced this pull request Apr 17, 2026
Similar to #699, adds a reusable Scorecard analysis workflow and
refactors `scorecards-analysis.yml` to call it.

Unlike the CodeQL workflow, which only relies on actions from
GitHub-owned organisations (`github` and `actions`), this one uses a
third-party action (`ossf/scorecard-action`) that needs to be upgraded
in a timely manner. The usual process is:

1. A new version of the action is released.
2. The action is reviewed in `infrastructure-actions` and the new SHA
   is added to the authorized ones.
3. The old SHA is scheduled for removal.

We need to perform the upgrade between steps 2 and 3, so we should
configure Dependabot to bump this action weekly with a 7-day cooldown
(step 2 occurs within 7 days of a new release).
ppkarwasz added a commit that referenced this pull request Apr 17, 2026
Similar to #699, adds a reusable Scorecard analysis workflow and
refactors `scorecards-analysis.yml` to call it.

Unlike the CodeQL workflow, which only relies on actions from
GitHub-owned organisations (`github` and `actions`), this one uses a
third-party action (`ossf/scorecard-action`) that needs to be upgraded
in a timely manner. The usual process is:

1. A new version of the action is released.
2. The action is reviewed in `infrastructure-actions` and the new SHA
   is added to the authorized ones.
3. The old SHA is scheduled for removal.

We need to perform the upgrade between steps 2 and 3, so we should
configure Dependabot to bump this action weekly with a 7-day cooldown
(step 2 occurs within 7 days of a new release).
It has a default value, so it can be optional.
@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@ppkarwasz
Copy link
Copy Markdown
Contributor Author

I hear you on complexity. The goal here isn't to replicate Log4j's setup, just to centralize the three workflows that we never debug: CodeQL, Scorecards, and Dependency Review.

The pain points with the status quo:

  • CodeQL stays stale between quarterly updates, so we don't profit from new static analysis rules,
  • 40+ Dependabot notifications per upgrade cycle,
  • SHA-pinned actions still need manual bumps everywhere

A reusable workflow for just these three would reduce churn without adding any meaningful cognitive overhead: they're essentially fire-and-forget.

Proposal: let's try it scoped to these three only. If debugging ever becomes an issue in a downstream repo, we inline it back. Does that work for you?

@garydgregory
Copy link
Copy Markdown
Member

CodeQL stays stale between quarterly updates, so we don't profit from new static analysis rules,

Not true. I've been updating the actions, as you can see the version is current (or should be since I updated them yesterday.)

The version checks are quarterly because a person I won't name changed them from weekly to quarterly in all components because "reasons" about their mailbox. This is a changes I formally voted -1 but I was told my vote didn't count for other "reasons".

This PR makes the build more complex and harder to maintain, so I am against it.

@aherbert
Copy link
Copy Markdown
Contributor

This should be discussed on the mailing list. I am in favour of trying it. I see this change as similar to the use of commons-parent in all derived projects. That is not without problems since each release cycle of a project typically uncovers an issue in commons parent. A fix integrated at the parent then cascades the fix to other projects, with some overhead to ensure the fix works.

If this is trialled and the maintenance and frequency of issues increases then we can stop the trial. But we will not know without a trial.

@ppkarwasz
Copy link
Copy Markdown
Contributor Author

Not true. I've been updating the actions, as you can see the version is current (or should be since I updated them yesterday.)

This means a lot of mechanical work for you, so you have less time to tasks that would actually benefit from your expertise. This is the main reason I hate Dependabot churn.

The version checks are quarterly because a person I won't name changed them from weekly to quarterly in all components because "reasons" about their mailbox. This is a changes I formally voted -1 but I was told my vote didn't count for other "reasons".

I fully support that decision for Maven, but we probably didn't discuss it enough for GitHub Actions. These can become deprecated if the GitHub API changes or the Node version they use becomes unsupported, so we have to upgrade them more often. On the other hand if we upgrade carelessly, GitHub Actions and NPM is the heaven of supply-chain attacks.

@ppkarwasz
Copy link
Copy Markdown
Contributor Author

Since we now have an overview of all the CodeQL workflows across repositories (#701), should I merge this PR and experimentally deploy the workflow across some projects? For example I could start with:

  • Codec
  • Collections
  • Compress
  • IO
  • Lang

What do you think?

@garydgregory
Copy link
Copy Markdown
Member

This will happen naturally as I've started a release train of most of these components. If you want to try one, try Collections, the others are in my release train.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants